package hspedu.learn.javabase.extendsImporve;

public class Base extends Object{
    public int n1 =999;
    public int age = 111;
    public void cal() {
        System.out.println("Base类的cal方法");
    }
    public void eat() {
        System.out.println("Base类的eat方法");
    }
}
class A extends Base {
//    public int n1 = 100;
    protected int n2 = 200;
    int n3 = 300;
    private int n4 = 400;
    public A() {}

    public A(String name ){

    }
    @Override
    public void cal() {
        System.out.println("A类的cal方法");
    }
}
class B extends A{
    public int n1 = 888;
    public void test() {
        //使用super要遵守就近访问的规则
        System.out.println(super.n1);
        super.cal();
    }
}
class Finish {
    public static void main(String[] args) {
        B b = new B();
        b.test();
    }

}